home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows News 2010 Summer - Disc 1
/
WN_Ete2010_CD1.iso
/
Onglet5
/
Weezo
/
Weezo setup.exe
/
{code_appDir}
/
www
/
res
/
blog
/
selfBlog
/
upload.php
< prev
Wrap
PHP Script
|
2010-05-19
|
3KB
|
90 lines
<?php
/**
* Blog image upload script
*
* Display "please wait" screen
* Upload an image to server, resize it and put it in blog temp directory
*
* If no file is sent, display "please wait" screen and call doSendImage script in opener window
* This script submit file send form, targeting current widows
* file reception is then detected.
*
* PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
* @category NA
* @package NA
* @author Nicolas Bruley / Peer 2 World <contact@weezo.net>
* @copyright 2005-2009 Nicolas Bruley / Peer 2 World
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id:$
* @link http://www.weezo.net
* @since File available since Release 1.0.0
*/
require_once('uploadWindow.php');
function processUploadedFile(){
global $transfersArray;
$errorMessage=false;
// Move uploaded file to resource directory
$uploadDir = cfAppResourceDir();
$uploadFile = $uploadDir . '/tmp.'.cfFileExtension(basename($_FILES['ulInput']['name']));
if(!move_uploaded_file($_FILES['ulInput']['tmp_name'], $uploadFile)){
$fileTransfered=false;
$errorMessage = cfCaption('genError');
}
else $fileTransfered=true;
// Verify that it is an image
if(!$errorMessage && substr($_FILES['ulInput']['type'],0,5)!='image') {
$errorMessage=cfCaption('blogErrorNotImage');
$fileTransfered=false;
unlink($uploadFile);
}
// Verify that user has administrator rights
if(!$errorMessage && !cfUGetVar('administrator')){
$errorMessage = cfCaption('genError');
$fileTransfered=false;
unlink($uploadFile);
}
// Output size
$dW=150;$dH=150;
if(!$errorMessage && isset($_POST['size'])){
switch ($_POST['size']){
case 'big':$dW=600;$dH=600;break;
case 'medium':$dW=300;$dH=300;break;
case 'small':$dW=150;$dH=150;break;
default:$dW=150;$dH=150;break;
}
}
// Output position
if(!$errorMessage){
cfRSetVar('uploadedImagePosition','top');
if(isset($_POST['position'])){
switch ($_POST['position']){
case 'top':cfRSetVar('uploadedImagePosition','top'); break;
case 'bottom':cfRSetVar('uploadedImagePosition','bottom');break;
}
}
}
// Generate jpg image from sent image
if(!$errorMessage){
cfCreateResizedJPG($uploadFile, 0, 0, $uploadDir.'/tmpImg.jpg', $dW,$dH); unlink($uploadFile);
cfRSetVar('uploadedImage',true);
}
// Display upload completed page
if(!$errorMessage) displayUploadCompletedPage($uploadDir.'/tmpImg.jpg',false);
else displayUploadCompletedPage(false,$errorMessage);
}
?>